﻿@page "/SysConfigGroup/Edit/{id}"
@using SelfService.ViewModel.SysConfigGroupVMs;
@inherits BasePage

<ValidateForm @ref="VForm" Model="@_model" OnValidSubmit="@Submit">
    <Row ItemsPerRow="ItemsPerRow.Two" RowType="RowType.Normal">
        <BootstrapInput @bind-Value="@_model.Entity.Key"  />
        <BootstrapInput @bind-Value="@_model.Entity.Name"  />
        <BootstrapInput @bind-Value="@_model.Entity.Description"  />
    </Row>
    <div class="modal-footer table-modal-footer">
        <Button Color="Color.Warning" Icon="fa fa-close" Text="@WtmBlazor.Localizer["Sys.Close"]" OnClick="OnClose"></Button>
        <Button Color="Color.Primary" ButtonType="ButtonType.Submit" Icon="fa fa-save" Text="@WtmBlazor.Localizer["Sys.Edit"]" IsAsync="true"></Button>
    </div>
</ValidateForm>

@code {

    private SysConfigGroupVm _model = null;
    private ValidateForm VForm { get; set; }
    [Parameter]
    public string id { get; set; }

    protected override async Task OnInitializedAsync()
    {
        var rv = await WtmBlazor.Api.CallAPI<SysConfigGroupVm>($"/api/SysConfigGroup/{id}");
        _model = rv.Data;
         await base.OnInitializedAsync();
   }

    private async Task Submit(EditContext context)
    {
        await PostsForm(VForm, $"/api/SysConfigGroup/edit", (s) => "Sys.OprationSuccess", method: HttpMethodEnum.PUT);
    }

    public void OnClose()
    {
        CloseDialog();
    }

}
